package com.linearList;

import org.junit.Before;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

/**
 * @Author: linKe
 * @Date: 2021/12/30 12:13
 * @FileName: SinglyListTest
 * @version: 1.0
 * @Description: 单链表数据结构实现的测试类
 *
 */
public class SinglyListTest {

    private SinglyList<Integer> list;

    @Before
    public void setUp() throws Exception {
        Integer[] arr = {1,2,3,5,6};
        list = new SinglyList<Integer>(arr);
       //list.insert(1,3);
    }

    @Test
    public void isEmpty() {
        //false 返回非空判断的结果
        System.out.println(list.isEmpty());
    }

    @Test
    public void get() {
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        System.out.println(list.get(2));
        System.out.println(list.get(3));
        System.out.println(list.get(4));
        System.out.println(list.get(5));
        System.out.println(list.toString());
        /*
        1
        2
        3
        5
        6
        null
        com.linearList.SinglyList@2b05039f
        * */
    }

    @Test
    public void set() {
        list.set(2,4);
        Integer integer = list.get(2);
        //返回结点修改后值4
        System.out.println(integer);
    }

    @Test
    public void size() {
        //返回结点的长度
        System.out.println(list.size());
    }

    @Test
    public void insert() {
        Node<Integer> node = list.insert(6, 3);
        //返回结点值3
        System.out.println(node);
    }

    @Test
    public void remove() {
        Integer remove = list.remove(5);
        //null 返回删除的结点值
        System.out.println(remove);
    }

    @Test
    public void search() {
        Node<Integer> search = list.search(3);
        //3 返回对应的结点序号
        System.out.println(search);
    }

    @Test
    public void testEquals() {
        SinglyList<Integer> lis = new SinglyList<>();
        //false 返回重写equals的比较结果
        boolean equals = list.equals(lis);
        System.out.println(equals);
    }
}